package com.lee.springCloud.controller;

import com.lee.springCloud.domain.CommonResult;
import com.lee.springCloud.domain.Payment;
import com.lee.springCloud.serveice.PaymentService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Lee
 * @createDate 2021/12/22 14:10
 */
@Controller
public class PaymentController {
    @Resource
    private PaymentService paymentService;
    @Value("${server.port}")
    private String serverPort;

    @PostMapping(value = "/payment/create")
    @ResponseBody
    public CommonResult create(@RequestBody Payment payment){
        CommonResult commonResult = paymentService.create(payment);
        return commonResult;
    }

    @GetMapping(value = "/payment/get/{id}")
    @ResponseBody
    public CommonResult getPaymentById(@PathVariable("id") Long id){
        CommonResult commonResult = paymentService.getPaymentById(id);
        return commonResult;
    }

    @GetMapping("/payment/lb")
    @ResponseBody
    public String getPaymentLb(){
        return serverPort;
    }
}
